package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;
import java.util.Set;

@Mapper
public interface OrderSettingMapper {
    /**
     * 根据日期查询预约设置数据
     * @param orderDate
     * @return
     */
    @Select("select count(*) from t_ordersetting where order_date = #{orderDate}")
    Integer countByDate(LocalDate orderDate);

    /**
     * 根据日期更新预约设置数据
     * @param orderSetting
     */
    @Update("update t_ordersetting set number = #{number} where order_date = #{orderDate}")
    void update(OrderSetting orderSetting);

    /**
     * 批量导入预约设置数据
     * @param orderSettingList
     */
    void insertBatch(List<OrderSetting> orderSettingList);

    /**
     * 根据日期范围查询预约设置数据
     * @param firstDay
     * @param endDay
     * @return
     */
    @Select("select id, order_date, number, reservations" +
            " from t_ordersetting where order_date between #{firstDay} and #{endDay}")
    List<OrderSetting> selectByDate(LocalDate firstDay, LocalDate endDay);

    /**
     * 根据日期集合删除预约设置数据
     * @param dateSet
     */
    void deleteByDates(Set<LocalDate> dateSet);
}
